* {
  box-sizing: border-box;
}
/* 布局相关样式 - 不依赖主题变量 */
html {
  font-size: var(--font-size, 14px);
}

body {
  margin: 0;
  padding: 40px;
  line-height: var(--line-height, 1.6);
  font-family: var(--font-family, var(--vscode-editor-font-family));
  background-color: var(--editor-background, var(--vscode-editor-background));
  color: var(--editor-foreground, var(--vscode-foreground));
  /* 优化滚动性能 */
  overflow-x: hidden;
  will-change: scroll-position;
}

.container {
  max-width: var(--document-width, 800px);
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

/* 选择样式 */
::selection {
  background: var(--editor-selectionBackground);
}

/* 块引用样式 */
blockquote {
  color: var(--markdown-darkened-foreground);
  background-color: var(--markdown-blockQuote-background-level1);
  border-left: 4px solid var(--markdown-blockQuote-border);
  padding: 0.5rem 1rem;
  margin: 0 0 1rem 0;
}

/* blockquote嵌套层级样式 */
blockquote blockquote {
  background-color: var(--markdown-blockQuote-background-level2);
  border-left-width: 3px;
}

blockquote blockquote blockquote {
  background-color: var(--markdown-blockQuote-background-level3);
  border-left-width: 2px;
}

blockquote blockquote blockquote blockquote {
  background-color: var(--markdown-blockQuote-background-level4);
  border-left-width: 2px;
}

blockquote blockquote blockquote blockquote blockquote {
  background-color: var(--markdown-blockQuote-background-level5);
  border-left-width: 2px;
}

/* 表格样式 */
th,
td {
  border: 1px solid var(--markdown-table-border);
  padding: 0.5rem 0.75rem;
}

th {
  background-color: var(--markdown-tableHeader-background);
  color: var(--editor-foreground);
  font-weight: 600;
}

/* 单行代码样式 */
code {
  background-color: var(--markdown-code-background);
  color: var(--textLink-foreground);
  padding: 0.125rem 0.25rem;
  margin: 0;
  border-radius: 0.25em;
  font-family: var(--font-family, var(--vscode-editor-font-family));
}

/* 代码块 */
pre code {
  background-color: transparent;
  padding: 0;
  margin: 0;
  font-size: 100%;
  border-radius: 0;
}

pre {
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
  background-color: var(--markdown-codeBlock-background, var(--vscode-textCodeBlock-background)) !important;
}

pre.shiki {
  padding: 16px 0;
}

pre.shiki .line {
  padding-left: 16px;
  padding-right: 16px;
}
/* 行高亮样式 */
pre.shiki .line.highlighted {
  width: 100% !important;
  display: inline-block !important;
  background-color: var(--markdown-blockQuote-background-level2) !important;
}

/* 链接样式 */
a {
  color: var(--textLink-foreground, var(--vscode-textLink-foreground)) !important;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: var(--textLink-foreground, var(--vscode-textLink-foreground));
}

a:focus {
  outline: 0.125rem solid var(--textLink-foreground, var(--vscode-textLink-activeForeground));
  outline-offset: 0.125rem;
}

/* 标题样式 */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 2rem;
  border-bottom: 1px solid var(--markdown-blockQuote-border);
  padding-bottom: 0.3em;
}

h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--markdown-blockQuote-border);
  padding-bottom: 0.3em;
}

h3 {
  font-size: 1.25rem;
}
h4 {
  font-size: 1rem;
}
h5 {
  font-size: 0.875rem;
}
h6 {
  font-size: 0.85rem;
}

hr {
  border-color: var(--markdown-blockQuote-border, var(--vscode-textBlockQuote-border));
}

/* 列表样式 */
ul,
ol {
  padding-left: 2rem;
}

li + li {
  margin-bottom: 0.25em;
}

ul ul,
ol ol,
ul ol,
ol ul {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* 表格样式增强 */
table {
  border-collapse: collapse;
  border-spacing: 0;
  margin-bottom: 1rem;
  width: max-content;
}

table th:first-child,
table td:first-child {
  border-left: none;
}

table th:last-child,
table td:last-child {
  border-right: none;
}

/* 折叠内容样式 */
details {
  margin: 1rem 0;
  border: 1px solid var(--markdown-table-border);
  border-radius: 0.375rem;
  background-color: var(--markdown-codeBlock-background);
  transition: border-color 0.2s ease;
}

details:hover {
  border-color: var(--markdown-blockQuote-border);
}

summary {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 600;
  background-color: var(--markdown-tableHeader-background);
  user-select: none;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

summary:hover {
  background-color: var(--editor-foldBackground);
}

/* 添加折叠图标 */
summary::before {
  content: '▶';
  display: inline-block;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: var(--markdown-darkened-foreground);
}

details[open] summary {
  border-radius: 6px;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details > *:not(summary) {
  padding: 0 1rem 1rem 1rem;
}

/* details 内部容器样式 */
.details-inner {
  padding: 1em;
}

details[open] .details-inner {
  padding: 1em;
}

details.highlight {
  border-color: var(--textLink-foreground);
  background-color: var(--markdown-blockQuote-background-level1);
}

details.highlight summary {
  background-color: var(--markdown-blockQuote-background-level2);
}

/* 嵌套的details容器样式 */
details details {
  margin: 0.75rem 0;
  margin-left: 1rem;
  border-color: var(--markdown-darkened-foreground);
}

details details summary {
  background-color: var(--markdown-codeBlock-background);
  font-size: 0.9rem;
}

/* 嵌套details的内容区域增加左边距 */
details details > *:not(summary) {
  padding-left: 0.5rem;
}

/* 多层嵌套的递进缩进 */
details details details {
  margin-left: 2rem;
}

details details details > *:not(summary) {
  padding-left: 1rem;
}

details details details details {
  margin-left: 3rem;
}

details details details details > *:not(summary) {
  padding-left: 1.5rem;
}
details pre.shiki {
  border: 0.3px solid var(--markdown-table-border);
}

/* 空内容的details容器 */
details:empty::after {
  content: '无内容';
  display: block;
  padding: 1rem;
  color: var(--markdown-darkened-foreground);
  font-style: italic;
}

/* 图片样式 */
img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.1);
  margin: 0.5rem 0;
}

/* 文本强调元素样式 */
strong,
b {
  font-weight: 600;
}

i {
  font-style: italic;
  color: var(--editor-foreground);
}

del,
s {
  text-decoration: line-through;
  opacity: 0.7;
}

ins {
  text-decoration: underline;
  background-color: var(--markdown-blockQuote-background-level1);
  padding: 0.1em 0.2em;
  border-radius: 3px;
}

mark {
  background-color: #fff3cd;
  color: #856404;
  padding: 0.1em 0.2em;
  border-radius: 0.1875rem;
}

u {
  text-decoration: underline;
}

/* 脚注样式 */
.footnote-ref {
  font-size: 0.8rem;
  vertical-align: super;
  color: var(--textLink-foreground);
  text-decoration: none;
  margin-left: 0.2rem;
}

.footnote-ref:hover {
  text-decoration: underline;
}

.footnotes {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--markdown-table-border);
  font-size: 0.9rem;
}

.footnotes ol {
  padding-left: 1.5rem;
}

.footnotes li {
  margin-bottom: 0.5em;
}

/* 定义列表样式 */
dl {
  margin: 1rem 0;
}

dt {
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

dd {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--editor-foreground);
}

/* 任务列表样式 */
.task-list-item {
  list-style-type: none;
  margin-left: -1.5em;
}

.task-list-item input[type='checkbox'] {
  margin-right: 0.5rem;
  vertical-align: middle;
}

.task-list-item input[type='checkbox']:checked + * {
  text-decoration: line-through;
  opacity: 0.7;
}

/* 其他语义元素样式 */
kbd {
  background-color: var(--markdown-codeBlock-background);
  border: 1px solid var(--markdown-table-border);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--markdown-table-border);
  color: var(--editor-foreground);
  display: inline-block;
  font-family: var(--font-family, var(--vscode-editor-font-family));
  font-size: 0.9rem;
  padding: 0.2em 0.4em;
  white-space: nowrap;
}

samp {
  background-color: var(--markdown-codeBlock-background);
  color: var(--editor-foreground);
  font-family: var(--font-family, var(--vscode-editor-font-family));
  font-size: 0.9rem;
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

var {
  font-style: italic;
  color: var(--textLink-foreground);
}

cite {
  font-style: italic;
}

abbr {
  border-bottom: 1px dotted var(--markdown-table-border);
  cursor: help;
}

dfn {
  font-style: italic;
  font-weight: 600;
}

sub,
sup {
  font-size: 0.75rem;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

small {
  font-size: 0.875rem;
  opacity: 0.8;
}

big {
  font-size: 1.125rem;
}

/* 引用样式增强 */
blockquote p:last-child {
  margin-bottom: 0;
}

/* 自定义容器样式 */
.custom-container {
  margin: 1.5rem 0;
  padding: 1rem;
  border-radius: 6px;
  border-left: 4px solid;
}

.custom-container.info {
  border-left-color: #aaabb0;
  background-color: rgba(141, 145, 150, 0.16);
}

.custom-container.info::before {
  content: 'INFO';
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #aaabb0;
  padding-left: 1.5rem;
  position: relative;
}

.custom-container.info::before {
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
  -webkit-mask-position: 0 50%;
  mask-position: 0 50%;
  -webkit-mask-size: 1em;
  mask-size: 1.3rem;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.custom-container.warning {
  border-left-color: #ffc107;
  background-color: rgb(234 179 8 / 16%);
}

.custom-container.warning::before {
  content: 'WARNING';
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #ffc107;
  padding-left: 1.5rem;
  position: relative;
}

.custom-container.warning::before {
  background-color: currentColor;
  mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'%3E%3Cpath d='M576.286 752.57v-95.425q0-7.031-4.771-11.802t-11.3-4.772h-96.43q-6.528 0-11.3 4.772t-4.77 11.802v95.424q0 7.031 4.77 11.803t11.3 4.77h96.43q6.528 0 11.3-4.77t4.77-11.803zm-1.005-187.836 9.04-230.524q0-6.027-5.022-9.543-6.529-5.524-12.053-5.524H456.754q-5.524 0-12.053 5.524-5.022 3.516-5.022 10.547l8.538 229.52q0 5.023 5.022 8.287t12.053 3.265h92.913q7.032 0 11.803-3.265t5.273-8.287zM568.25 95.65l385.714 707.142q17.578 31.641-1.004 63.282-8.538 14.564-23.354 23.102t-31.892 8.538H126.286q-17.076 0-31.892-8.538T71.04 866.074q-18.582-31.641-1.004-63.282L455.75 95.65q8.538-15.57 23.605-24.61T512 62t32.645 9.04 23.605 24.61z'/%3E%3C/svg%3E");
  mask-position: 0 50%;
  mask-size: 1.3rem;
  mask-repeat: no-repeat;
}

.custom-container.danger {
  border-left-color: #dc3545;
  background-color: rgb(244 63 94 / 16%);
}

.custom-container.danger::before {
  content: 'DANGER';
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #dc3545;
  padding-left: 1.5rem;
  position: relative;
}

.custom-container.danger::before {
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
  mask-position: 0 50%;
  mask-size: 1.3rem;
  mask-repeat: no-repeat;
}

.custom-container.tip {
  background-color: rgb(16 185 129 / 16%);
  border-left-color: #3dd68c;
}

.custom-container.tip::before {
  content: 'TIP';
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #3dd68c;
  padding-left: 1.5rem;
  position: relative;
}

.custom-container.tip::before {
  background-color: currentColor;
  mask-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.941 18c-.297-1.273-1.637-2.314-2.187-3a8 8 0 1 1 12.49.002c-.55.685-1.888 1.726-2.185 2.998H7.94zM16 20v1a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-1h8zm-3-9.995V6l-4.5 6.005H11v4l4.5-6H13z'/%3E%3C/svg%3E");
  mask-position: 0 50%;
  mask-size: 1.3rem;
  mask-repeat: no-repeat;
}

.custom-container p:first-child {
  margin-top: 0;
}

.custom-container p:last-child {
  margin-bottom: 0;
}

/* 代码块语言显示样式 */
.lang {
  position: absolute;
  top: 4px;
  right: 4px;
  color: var(--editor-foreground);
  font-size: 10px;
  font-weight: 500;
  border-radius: 3px;
  z-index: 5;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-family: var(--font-family, var(--vscode-editor-font-family));
  letter-spacing: 0.5px;
}

/* 复制按钮样式 */
.copy-button {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 4px;
  color: var(--editor-foreground);
  background: rgba(0, 0, 0, 0.15);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s;
  z-index: 10;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
}

.copy-button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.25);
}

pre:hover .copy-button {
  display: flex !important;
}
pre:hover .lang {
  opacity: 0;
}
/* 复制按钮状态样式 */
.copy-button.copied {
  color: #4caf50 !important;
  opacity: 1;
  background: rgba(76, 175, 80, 0.2) !important;
}

.copy-button.failed {
  color: #f44336 !important;
  background: rgba(244, 67, 54, 0.1) !important;
}

/* Notion风格目录样式 */
.notion-toc-container {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  user-select: none;
}

.notion-toc-minimal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px;
}

.toc-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  align-items: flex-end;
}

.toc-line {
  cursor: pointer;
  padding: 2px 0;
  transition: all 0.2s ease;
  display: flex;
  justify-content: flex-end;
}

.toc-line:hover {
  transform: scale(1.1);
}

.toc-line-bar {
  background-color: var(--editor-foreground, var(--vscode-foreground));
  height: 2px;
  opacity: 0.25;
  transition: opacity 0.2s;
  box-shadow: none;
  border-radius: 1px;
}

.toc-line-bar.active {
  opacity: 1;
  box-shadow: var(--editor-foreground, var(--vscode-foreground)) 0px 0px 3px;
}

/* 详细菜单样式 */
.notion-toc-detailed {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background-color: var(--editor-background, var(--vscode-editor-background));
  border: 1px solid var(--markdown-blockQuote-background-level3);
  border-radius: 8px;
  padding: 10px;
  /* box-shadow: 0 0 6px var(--markdown-blockQuote-background-level1); */
  backdrop-filter: blur(10px);
  min-width: 200px;
  max-width: 240px;
  max-height: 400px;
  overflow-y: auto;
}

.toc-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item {
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-size: 12px;
  color: var(--editor-foreground, var(--vscode-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item:hover {
  background-color: var(--markdown-blockQuote-background-level1);
}

.toc-item.active {
  background-color: var(--markdown-blockQuote-background-level3);
  color: var(--textLink-foreground);
}
.mord {
  letter-spacing: 0.1em;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .notion-toc-container {
    right: 10px;
  }
}

/* Mermaid 图表样式 */
.mermaid-graph {
  text-align: center;
  margin: 20px 0;
  padding: 20px;
  background-color: var(--markdown-codeBlock-background, var(--vscode-textCodeBlock-background)) !important;
  border-radius: 6px;
  overflow-x: auto;
  filter: brightness(1) contrast(1);
}

.mermaid-graph svg {
  max-width: 100%;
  height: auto;
}

.mermaid-error {
  color: var(--vscode-errorForeground, #f14c4c);
  background-color: var(--vscode-inputValidationErrorBackground, rgba(255, 0, 0, 0.05));
  border: 1px solid var(--vscode-inputValidationErrorBorder, #f14c4c);
  border-radius: 4px;
  padding: 8px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
}
